<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body,html{
            margin: 100px auto;
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
        }
        .box {
            overflow: hidden;
            width: 400px;
            height: 500px;
            text-align: center;
        }
        .content{
            width: 100%;
            height: 300px;
            color: #ddd;
            font-size: 100px;
            line-height: 300px;
            text-shadow: 0 0 10px rgb(33, 32, 32);
        }
        .click{
            margin: 0 auto;
           width: 100px;
           height: 100px;
           line-height: 100px;
           font-size: 40px;
           font-weight: 600;
           border: 10px solid #555;
           border-radius: 50%;
        }
    </style>
</head>
<body>
    <div class="box">
         <div class="content">随机抽取</div>
         <div class="click">开始</div>
    </div>
    <script>
        window.onload = () =>{
            const content = document.querySelector('.content');
            const click = document.querySelector('.click');
            let uname = ['刘德华', '郭富城', '古天乐', '周星驰', '李连杰', '胡歌', '张学友', '吴孟达', '林俊杰', '洪金宝', '周杰伦'];
            let flag = true;
            let time = null
            // 添加点击事件
            click.addEventListener('click', () =>{
                if(flag){
                    time = setInterval(() =>{
                       let digit = Math.floor(Math.random() * uname.length);
                       content.innerHTML = uname[digit];
                       click.innerHTML = '停止';
                    },10)
                }else {
                    clearInterval(time);
                    click.innerHTML = '继续';
                }
                flag =!flag
            })
        }
    </script>
</body>
</html>